<?php
include ('top.ajax.php');

if(isset($_POST['id'])) {

$sharing=new Sharing($_POST['id']); 
$db=Database::getInstance();
$sql="SELECT * FROM sharing_isvendor WHERE id_sharing='".$_POST['id']."'";
$result=$db->query($sql);
if(sizeof($result)>0) {
$vendor=new Vendor($result[0]['id_vendor']);
$vendor->load();
$brand=Brand::getFromName($vendor['nom']);
}



if((isset($brand['id']))&&(isset($vendor['id']))) {
$db=Database::getInstance();
$sql="DELETE FROM brands_vendors_link WHERE vendor_id='".$vendor['id']."'";
$result=$db->query($sql);
$sql="DELETE FROM sharing_isvendor WHERE id_sharing='".$_POST['id']."'";
$result=$db->query($sql);
$brand->delete();
$vendor->delete();
}

$sharing->delete();



}

?>